#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>

int main()
{
	int m = 0;
	int n = 0;
	scanf("%d %d", &m, &n);
	int arr1[1000];
	int arr2[1000];
	int arr3[2000];
	int i = 0;
	int j = 0;
	int k = 0;
	for (i = 0; i < m; i++)
	{
		scanf("%d", &arr1[i]);
	}
	for (i = 0; i < n; i++)
	{
		scanf("%d", &arr2[i]);
	}
	i = 0;
	while (i < m && j < n)
	{
		if (arr1[i] < arr2[j])
			arr3[k++] = arr1[i++];
		else
			arr3[k++] = arr2[j++];
	}
	if (i == m)
	{
		while (j < n)
			arr3[k++] = arr2[j++];
	}
	else
	{
		while (i < m)
			arr3[k++] = arr1[i++];
	}
	for (int p = 0; p < m + n; p++)
	{
		printf("%d ", arr3[p]);
	}
	return 0;
}